package com.znxs.user_center_c.common;

/**
 * 通用返回对象工具类
 */
public class ResultUtils {

    public static <T> BaseResponse<T> success(T data){
        return  new BaseResponse<>(200,data,"ok",null);
    }

    public static <T> BaseResponse<T> success(String description){
        return  new BaseResponse<>(200,null,"ok",description);
    }

    public static <T> BaseResponse<T> error (ErrorCode errorCode){
        return new BaseResponse<>(errorCode.getCode(),null,errorCode.getMessage(),errorCode.getDescription());
    }

    public static BaseResponse error(int code, String message, String description) {
        return new BaseResponse<>(code,null,message,description);
    }

    public static BaseResponse error(ErrorCode errorCode, String message, String s) {
        return new BaseResponse<>(errorCode.getCode(),null,message,s);
    }

    public static BaseResponse error(ErrorCode errorCode, String description) {
        return new BaseResponse<>(errorCode.getCode(),null,errorCode.getMessage(),description);
    }
}
